/*
Macromedia(r) Flash(r) JavaScript Integration Kit License


Copyright (c) 2005 Macromedia, inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment:

"This product includes software developed by Macromedia, Inc.
(http://www.macromedia.com)."

Alternately, this acknowledgment may appear in the software itself, if and
wherever such third-party acknowledgments normally appear.

4. The name Macromedia must not be used to endorse or promote products derived
from this software without prior written permission. For written permission,
please contact devrelations@macromedia.com.

5. Products derived from this software may not be called "Macromedia" or
"Macromedia Flash", nor may "Macromedia" or "Macromedia Flash" appear in their
name.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MACROMEDIA OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

--

This code is part of the Flash / JavaScript Integration Kit:
http://www.macromedia.com/go/flashjavascript/

Created by:

Christian Cantrell
http://weblogs.macromedia.com/cantrell/
mailto:cantrell@macromedia.com

Mike Chambers
http://weblogs.macromedia.com/mesh/
mailto:mesh@macromedia.com

Macromedia
*/
function FlashProxy(lcId,flashId,proxySwfName,callbackScope){FlashProxy.fpmap[lcId]=this;this.uid=lcId;this.proxySwfName=proxySwfName;this.callbackScope=callbackScope;this.flashSerializer=new FlashSerializer(false);this.q=[];if(navigator.appName.indexOf("Internet Explorer")!=-1&&navigator.platform.indexOf("Win")!=-1&&navigator.userAgent.indexOf("Opera")==-1){setUpVBCallback(flashId)}}
FlashProxy.prototype.call=function(){if(arguments.length==0){throw new Exception("Flash Proxy Exception","The first argument should be the function name followed by any number of additional arguments.");}this.q.push(arguments);if(this.q.length==1){this._execute(arguments)}}
;FlashProxy.prototype._execute=function(args){var ft=new FlashTag(this.proxySwfName,1,1,"6,0,65,0");ft.addFlashVar("lcId",this.uid);ft.addFlashVar("functionName",args[0]);if(args.length>1){var justArgs=[];for(var i=1;i<args.length;++i){justArgs.push(args[i])}ft.addFlashVars(this.flashSerializer.serialize(justArgs))}var divName="_flash_proxy_"+this.uid;if(!document.getElementById(divName)){var newTarget=document.createElement("div");newTarget.id=divName;document.body.appendChild(newTarget)}var target=
document.getElementById(divName);target.innerHTML=ft.toString()}
;FlashProxy.callJS=function(command,args){var argsArray=eval(args);var scope=FlashProxy.fpmap[argsArray.shift()].callbackScope;if(scope&&command.indexOf(".")<0){var functionToCall=scope[command];functionToCall.apply(scope,argsArray)}else{var functionToCall=eval(command);functionToCall.apply(functionToCall,argsArray)}}
;FlashProxy._ping=function(lcId){var flashProxy=FlashProxy.fpmap[lcId];if(flashProxy.pongSent==true){return}flashProxy.pongSent=true;flashProxy.call("_pong")}
;FlashProxy.callComplete=function(uid){var fp=FlashProxy.fpmap[uid];if(fp!=null){fp.q.shift();if(fp.q.length>0){fp._execute(fp.q[0])}}}
;FlashProxy.fpmap={};
function Exception(name,message){if(name)this.name=name;if(message)this.message=message}
Exception.prototype.setName=function(name){this.name=name}
;Exception.prototype.getName=function(){return this.name}
;Exception.prototype.setMessage=function(msg){this.message=msg}
;Exception.prototype.getMessage=function(){return this.message}
;
function FlashSerializer(useCdata){this.useCdata=useCdata}
FlashSerializer.prototype.serialize=function(args){var qs=new String;for(var i=0;i<args.length;++i){switch(typeof args[i]){case "undefined":qs+="t"+i+"=undf";break;case "string":qs+="t"+i+"=str&d"+i+"="+escape(args[i]);break;case "number":qs+="t"+i+"=num&d"+i+"="+escape(args[i]);break;case "boolean":qs+="t"+i+"=bool&d"+i+"="+escape(args[i]);break;case "object":if(args[i]==null){qs+="t"+i+"=null"}else if(args[i]instanceof Date){qs+="t"+i+"=date&d"+i+"="+escape(args[i].getTime())}else{try{qs+="t"+i+
"=xser&d"+i+"="+escape(this._serializeXML(args[i]))}catch(exception){throw new Exception("FlashSerializationException","The following error occurred during complex object serialization: "+exception.getMessage());}}break;default:throw new Exception("FlashSerializationException","You can only serialize strings, numbers, booleans, dates, objects, arrays, nulls, and undefined.");}if(i!=args.length-1){qs+="&"}}return qs}
;FlashSerializer.prototype._serializeXML=function(obj){var doc={};doc.xml="<fp>";try{this._serializeNode(obj,doc,null)}catch(exception){if(exception.message){throw new Exception("FlashSerializationException","Unable to serialize object because: "+exception.message);}throw exception;}doc.xml+="</fp>";return doc.xml}
;FlashSerializer.prototype._serializeNode=function(obj,doc,name){switch(typeof obj){case "undefined":doc.xml+="<undf"+this._addName(name)+"/>";break;case "string":doc.xml+="<str"+this._addName(name)+">"+this._escapeXml(obj)+"</str>";break;case "number":doc.xml+="<num"+this._addName(name)+">"+obj+"</num>";break;case "boolean":doc.xml+="<bool"+this._addName(name)+' val="'+obj+'"/>';break;case "object":if(obj==null){doc.xml+="<null"+this._addName(name)+"/>"}else if(obj instanceof Date){doc.xml+="<date"
+this._addName(name)+">"+obj.getTime()+"</date>"}else if(obj instanceof Array){doc.xml+="<array"+this._addName(name)+">";for(var i=0;i<obj.length;++i){this._serializeNode(obj[i],doc,null)}doc.xml+="</array>"}else{doc.xml+="<obj"+this._addName(name)+">";for(var n in obj){if(typeof obj[n]=="function")continue;this._serializeNode(obj[n],doc,n)}doc.xml+="</obj>"}break;default:throw new Exception("FlashSerializationException","You can only serialize strings, numbers, booleans, objects, dates, arrays, nulls and undefined"
);break}}
;FlashSerializer.prototype._addName=function(name){if(name!=null){return' name="'+name+'"'}return""}
;FlashSerializer.prototype._escapeXml=function(str){if(this.useCdata)return"<![CDATA["+str+"]]>";else return str.replace(/&/g,"&amp;").replace(/</g,"&lt;")}
;
function FlashTag(src,width,height,version){if(arguments.length<4){throw new Exception("RequiredParameterException","You must pass in a src, width, height, and version when creating a FlashTag.");}this.src=src;this.width=width;this.height=height;this.version=version;this.menu="false";this.id=null;this.flashVars=null;this.flashVarsStr=null;this.genericParam={};this.ie=navigator.appName.indexOf("Microsoft")!=-1?1:0}
FlashTag.prototype.setSource=function(src){this.src=src}
;FlashTag.prototype.setWidth=function(w){this.width=w}
;FlashTag.prototype.setHeight=function(h){this.h=h}
;FlashTag.prototype.setVersion=function(v){this.version=v}
;FlashTag.prototype.setId=function(id){this.id=id}
;FlashTag.prototype.setBgcolor=function(bgc){if(bgc.charAt(0)!="#"){bgc="#"+bgc}this.genericParam["bgcolor"]=bgc}
;FlashTag.prototype.addFlashVars=function(fvs){this.flashVarsStr=fvs}
;FlashTag.prototype.addFlashVar=function(n,v){if(this.flashVars==null){this.flashVars={}}this.flashVars[n]=v}
;FlashTag.prototype.removeFlashVar=function(n){if(this.flashVars!=null){this.flashVars[n]=null}}
;FlashTag.prototype.setSwliveconnect=function(swlc){this.genericParam["swliveconnect"]=swlc}
;FlashTag.prototype.setPlay=function(p){this.genericParam["play"]=p}
;FlashTag.prototype.setLoop=function(l){this.genericParam["loop"]=l}
;FlashTag.prototype.setMenu=function(m){this.genericParam["menu"]=m}
;FlashTag.prototype.setQuality=function(q){if(q!="low"&&q!="high"&&q!="autolow"&&q!="autohigh"&&q!="best"){throw new Exception("UnsupportedValueException",'Supported values are "low", "high", "autolow", "autohigh", and "best".');}this.genericParam["quality"]=q}
;FlashTag.prototype.setScale=function(sc){if(sc!="showall"&&sc!="noborder"&&sc!="exactfit"){throw new Exception("UnsupportedValueException",'Supported values are "showall", "noborder", and "exactfit".');}this.genericParam["scale"]=sc}
;FlashTag.prototype.setAlign=function(a){if(a!="l"&&a!="t"&&a!="r"&&a!="b"){throw new Exception("UnsupportedValueException",'Supported values are "l", "t", "r" and "b".');}this.genericParam["align"]=a}
;FlashTag.prototype.setSalign=function(sa){if(sa!="l"&&sa!="t"&&sa!="r"&&sa!="b"&&sa!="tl"&&sa!="tr"&&sa!="bl"&&sa!="br"){throw new Exception("UnsupportedValueException",'Supported values are "l", "t", "r", "b", "tl", "tr", "bl" and "br".');}this.genericParam["salign"]=sa}
;FlashTag.prototype.setWmode=function(wm){if(wm!="window"&&wm!="opaque"&&wm!="transparent"){throw new Exception("UnsupportedValueException",'Supported values are "window", "opaque", and "transparent".');}this.genericParam["wmode"]=wm}
;FlashTag.prototype.setBase=function(base){this.genericParam["base"]=base}
;FlashTag.prototype.setAllowScriptAccess=function(sa){if(sa!="never"&&sa!="always"){throw new Exception("UnsupportedValueException",'Supported values are "never" and "always".');}this.genericParam["allowScriptAccess"]=sa}
;FlashTag.prototype.toString=function(){var flashTag=new String;if(this.ie){flashTag+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';if(this.id!=null){flashTag+='id="'+this.id+'" '}flashTag+='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" ';flashTag+='width="'+this.width+'" ';flashTag+='height="'+this.height+'">';flashTag+='<param name="movie" value="'+this.src+'"/>';flashTag+='<param name="menu" value="false">';for(var n in this.genericParam)
{if(this.genericParam[n]!=null){flashTag+='<param name="'+n+'" value="'+this.genericParam[n]+'"/>'}}if(this.flashVars!=null){var fv=this.getFlashVarsAsString();if(fv.length>0){flashTag+='<param name="flashvars" value="'+fv+'"/>'}}flashTag+="</object>"}else
	{
		flashTag+='<embed src="'+this.src+'"';
		flashTag+=' width="'+this.width+'"';
		flashTag+=' height="'+this.height+'"';
		flashTag+=' type="application/x-shockwave-flash"';
		flashTag+=' menu="false"';
		flashTag+=' wmode="opaque"';
		if(this.id!=null){ flashTag+=' name="'+this.id+'"'}
		for(var n in this.genericParam)
		{
			if(this.genericParam[n]!=null)
			{
				flashTag+=" "+n+'="'+this.genericParam[n]+'"'
			}
		}
		if(this.flashVars!=null)
		{
			var fv=this.getFlashVarsAsString();
			if(fv.length>0)
			{
				flashTag+=' flashvars="'+fv+'"'
			}
		}
		
		flashTag+=' pluginspage="http://www.macromedia.com/go/getflashplayer">';flashTag+="</embed>"
		}
	return flashTag}
;FlashTag.prototype.write=function(doc){doc.write(this.toString())}
;FlashTag.prototype.getFlashVarsAsString=function(){var qs=new String;for(var n in this.flashVars){if(this.flashVars[n]!=null){qs+=escape(n)+"="+escape(this.flashVars[n])+"&"}}if(this.flashVarsStr!=null){return qs+this.flashVarsStr}return qs.substring(0,qs.length-1)}
;


